package com.bestcem.xm.user.dao.impl;

import com.bestcem.xm.user.dao.UserUserAuthLogDao;
import com.bestcem.xm.user.dao.mapper.UserUserAuthLogMapper;
import com.bestcem.xm.user.entity.mysql.UserAuthLog;
import com.bestcem.xm.user.entity.pojo.UserAuthLogDO;
import com.bestcem.xm.user.util.business.DataBaseUtil;
import com.bestcem.xm.user.util.convert.UserAuthLogConvert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 * 用户操作日志
 *
 * @author wangyunyun <yunyun.wang@idiaoyan.com>
 * @version v1.0
 * @date 2023/3/3 14:30
 */
@Repository
public class UserUserAuthLogDaoImpl implements UserUserAuthLogDao {

    @Resource
    private UserAuthLogConvert userAuthLogConvert;

    @Autowired
    private UserUserAuthLogMapper userUserAuthLogMapper;

    @Override
    public String insert(UserAuthLogDO userAuthLogDO) {
        // 设置参数
        UserAuthLog entity = userAuthLogConvert.doToMysql(userAuthLogDO);
        entity.setLogId(DataBaseUtil.generateId());
        DataBaseUtil.setCreateAndUpdateTime(entity);
        // 新增
        userUserAuthLogMapper.insertSelective(entity);
        return entity.getLogId();
    }

}
